#include "AudioRec.h"

AudioRec::AudioRec()
	:QObject()
{
	connect(&Arecord, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(RecordStoped(int, QProcess::ExitStatus)));
	qDebug() << "Info :" << "Demarage de l'enregistreur Audio : OK";
}

AudioRec::~AudioRec()
{
	qDebug() << "Info :" << "Arret de l'enregistreur Audio : OK";
}
void AudioRec::SetTitle(QString newAlbum)
{
	Album = newAlbum;
}
void AudioRec::SetArtist(QString newArtist)
{
	Artist = newArtist;
}
void AudioRec::SetAlbum(QString newTitle)
{
	Title = newTitle;
}
void AudioRec::StartRecord()
{
	qDebug() << "Info :" << "Demarage de l'enregistrement FLAC";
	Arecord.start("arecord -f dat -t wav /tmp/TmpRec.wav");
}
void AudioRec::StartEnc()
{
	qDebug() << "Info :" << "Debut de l'encodage";
}
void AudioRec::StopRecord()
{
	qDebug() << "Info :" << "Demande d'arret de l'enregistrement FLAC";
	Arecord.terminate();
}
void AudioRec::RecordStoped(int exitCode, QProcess::ExitStatus exitStatus)
{
	qDebug() << "Info :" << "Arret de l'enregistrement FLAC";
	emit RecordFinished();
}
void AudioRec::EncFinished()
{
	qDebug() << "Info :" << "Fin de l'encodage";
	emit EncodageFinished();
}